using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System;

using MyUtils;

namespace Test.MyUtils.WeakDelegate
{
	public class WeakEventPublisher : EventPublisher
	{
		Action _eventSimple;
		EventHandler<PropertyChangedEventArgs> _eventClassic;

		public override int EventSimpleSubscribers
		{
			get
			{
				if (_eventSimple == null)
				{
					return 0;
				}

				return (int)_eventSimple.Reflect("GetInvocationList.Length");
			}
		}

		public override event Action EventSimple
		{
			add { _eventSimple += new WeakEventHandler<Action>(value); }
			remove { }
		}

		public void OnEventSimple()
		{
			_eventSimple.Invoke();
		}

		public override event Action<int, long, Box<int>> EventParametrized
		{
			add { throw new NotImplementedException(); }
			remove { throw new NotImplementedException(); }
		}

		public override event Func<int> EventReturn
		{
			add { throw new NotImplementedException(); }
			remove { throw new NotImplementedException(); }
		}

		public override event Func<int, int> EventReturnParametrized
		{
			add { throw new NotImplementedException(); }
			remove { throw new NotImplementedException(); }
		}

		public override event EventHandler<PropertyChangedEventArgs> EventCustomClassic
		{
			add { _eventClassic += new WeakEventHandler<EventHandler<PropertyChangedEventArgs>>(value); }
			remove {  }
		}
	}
}